import 'package:demo/theme/app_text_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';

import '../../../../theme/app_colors.dart';
import 'id_info_controller.dart';

class IdInfoView extends GetView<IdInfoController> {
  const IdInfoView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color_bg,
      appBar: AppBar(title: Text('身份认证',style: text_title_black)),
      body: SingleChildScrollView(child: Column(children: [
        Container(
          color: const Color(0xFFE9F7FE),
          padding: EdgeInsets.symmetric(horizontal: 15.w,vertical: 9.w),
          width: Get.width,
          child: Text('请上传与实名信息一致的身份证照片进行认证' ,style: text_main_12)),
        SizedBox(height: 15.w),
        // 头像面
        Container(
          margin: EdgeInsets.only(left: 15.w,right: 15.w),
          padding: EdgeInsets.only(left: 15.w,right: 15.w,top: 15.w),
          decoration: BoxDecoration(
            color: Color_white,
            borderRadius: BorderRadius.only(topLeft: Radius.circular(8.w),topRight: Radius.circular(8.w))
          ),
          child:InkWell(
            onTap: () => controller.toScanIdCard(true),
            child: Container(
              width: Get.width,
              padding: EdgeInsets.all(15.w),
              decoration: BoxDecoration(
                color: const Color(0xffedf3f5),
                borderRadius: BorderRadius.all(Radius.circular(4.w))
              ),
              child: Row(
                mainAxisAlignment : MainAxisAlignment.spaceBetween,
                crossAxisAlignment : CrossAxisAlignment.start,
                children: [
                  Column(
                    crossAxisAlignment : CrossAxisAlignment.start,
                    children: [
                      Text('头像面',style: text_131732_14),
                      SizedBox(height: 6.w),
                      Text('上传您身份证头像面',style: text_grey_12)
                    ],
                  ),
                  Stack(
                    alignment : AlignmentDirectional.center,
                    children: [
                      Image.asset("assets/images/ic_id_front.png", width: 142.w, height: 90.w),
                      Obx(() => Visibility(
                        visible: controller.idFrontUrl.value.isNotEmpty,
                        child: Container(
                          width: 142.w,
                          height: 90.w,
                          padding: EdgeInsets.all(25.w),
                          decoration: BoxDecoration(
                              color: const Color(0x7E000000),
                              borderRadius: BorderRadius.all(Radius.circular(8.w))
                          ),
                          child: Image.asset("assets/images/ic_success.png",color: Color_main),
                        ),
                      ))
                    ],
                  )
                ],
              ),
            ),
          ),
        ),
        // 国徽面
        Container(
          margin: EdgeInsets.only(left: 15.w,right: 15.w),
          padding: EdgeInsets.only(left: 15.w,right: 15.w,top: 12.w),
          color: Color_white,
          child:InkWell(
            onTap: () => controller.toScanIdCard(false),
            child: Container(
              width: Get.width,
              padding: EdgeInsets.all(15.w),
              decoration: BoxDecoration(
                  color: const Color(0xffedf3f5),
                  borderRadius: BorderRadius.all(Radius.circular(4.w))
              ),
              child: Row(
                mainAxisAlignment : MainAxisAlignment.spaceBetween,
                crossAxisAlignment : CrossAxisAlignment.start,
                children: [
                  Column(
                    crossAxisAlignment : CrossAxisAlignment.start,
                    children: [
                      Text('国徽面',style: text_131732_14),
                      SizedBox(height: 6.w),
                      Text('上传您身份证国徽面',style: text_grey_12)
                    ],
                  ),
                  Stack(
                    alignment : AlignmentDirectional.center,
                    children: [
                      Image.asset("assets/images/ic_id_back.png", width: 142.w, height: 90.w),
                      Obx(() => Visibility(
                        visible: controller.idBackUrl.value.isNotEmpty,
                        child: Container(
                          width: 142.w,
                          height: 90.w,
                          padding: EdgeInsets.all(25.w),
                          decoration: BoxDecoration(
                              color: const Color(0x7E000000),
                              borderRadius: BorderRadius.all(Radius.circular(8.w))
                          ),
                          child: Image.asset("assets/images/ic_success.png",color: Color_main),
                        ),
                      ))
                    ],
                  )
                ],
              ),
            ),
          ),
        ),
        // 温馨提示
        Container(
            margin: EdgeInsets.symmetric(horizontal: 15.w),
            padding: EdgeInsets.symmetric(horizontal: 15.w,vertical: 12.w),
            width: Get.width,
            decoration: BoxDecoration(
                color: Color_white,
                borderRadius: BorderRadius.only(bottomLeft: Radius.circular(8.w),bottomRight: Radius.circular(8.w))
            ),
            child: Column(
                crossAxisAlignment : CrossAxisAlignment.start,
                children: [
                  Text('温馨提示' ,style: text_131732_12),
                  Text('务必保证拍摄时处于光线充足的环境下；\n证件本身不要发生弯折，污损；\n证件务必与摄像框对齐。' ,style: text_grey_10),
                ])
        ),

        SizedBox(height: 35.w),
        InkWell(
          highlightColor: Colors.transparent, // 透明色
          splashColor: Colors.transparent, // 透明色
          onTap: () => controller.submit(),
          child: Container(
              margin: EdgeInsets.symmetric(horizontal: 15.w),
              height: 45.w,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(25.w),
                color: Color_main,
              ),
              child: Center(child: Text("提交",style: text_white_16))),
        )
      ])),
    );
  }
}
